package lily.phs.object;

import lily.phs.database.Constants;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;


public class HuiZhenRecord implements Constants{
	
	private Context myContext;
	public int core_profileid=-1;
	public int core_state=-1;
	public int getCore_state() {
		return core_state;
	}
	public void setCore_state(int coreState) {
		core_state = coreState;
	}

	public String core_reason="";
	public String core_opinion="";
	public String core_inst_1="";
	public String core_inst_2="";
	public String core_inst_3="";
	public String core_inst_4="";
	public String core_inst_5="";
	public String core_doct_1="";
	public String core_doct_2="";
	public String core_doct_3="";
	public String core_doct_4="";
	public String core_doct_5="";
	public String core_doct="";
	public String core_date="";
	
	public HuiZhenRecord(Context context){
		this.myContext=context;
	}
	public int getCore_profileid() {
		return core_profileid;
	}
	public void setCore_profileid(int coreProfileid) {
		core_profileid = coreProfileid;
	}
	public String getCore_reason() {
		return core_reason;
	}
	public void setCore_reason(String coreReason) {
		core_reason = coreReason;
	}
	public String getCore_opinion() {
		return core_opinion;
	}
	public void setCore_opinion(String coreOpinion) {
		core_opinion = coreOpinion;
	}
	public String getCore_inst_1() {
		return core_inst_1;
	}
	public void setCore_inst_1(String coreInst_1) {
		core_inst_1 = coreInst_1;
	}
	public String getCore_inst_2() {
		return core_inst_2;
	}
	public void setCore_inst_2(String coreInst_2) {
		core_inst_2 = coreInst_2;
	}
	public String getCore_inst_3() {
		return core_inst_3;
	}
	public void setCore_inst_3(String coreInst_3) {
		core_inst_3 = coreInst_3;
	}
	public String getCore_inst_4() {
		return core_inst_4;
	}
	public void setCore_inst_4(String coreInst_4) {
		core_inst_4 = coreInst_4;
	}
	public String getCore_inst_5() {
		return core_inst_5;
	}
	public void setCore_inst_5(String coreInst_5) {
		core_inst_5 = coreInst_5;
	}
	public String getCore_doct_1() {
		return core_doct_1;
	}
	public void setCore_doct_1(String coreDoct_1) {
		core_doct_1 = coreDoct_1;
	}
	public String getCore_doct_2() {
		return core_doct_2;
	}
	public void setCore_doct_2(String coreDoct_2) {
		core_doct_2 = coreDoct_2;
	}
	public String getCore_doct_3() {
		return core_doct_3;
	}
	public void setCore_doct_3(String coreDoct_3) {
		core_doct_3 = coreDoct_3;
	}
	public String getCore_doct_4() {
		return core_doct_4;
	}
	public void setCore_doct_4(String coreDoct_4) {
		core_doct_4 = coreDoct_4;
	}
	public String getCore_doct_5() {
		return core_doct_5;
	}
	public void setCore_doct_5(String coreDoct_5) {
		core_doct_5 = coreDoct_5;
	}
	public String getCore_doct() {
		return core_doct;
	}
	public void setCore_doct(String coreDoct) {
		core_doct = coreDoct;
	}
	public String getCore_date() {
		return core_date;
	}
	public void setCore_date(String coreDate) {
		core_date = coreDate;
	}
	
	public void insertHuiZhenRecord(){
		ContentValues value;
		value = new ContentValues();
		value.put(CORE_PROFILEID, this.getCore_profileid());
		value.put(CORE_STATE, this.getCore_state());
		value.put(CORE_REASON, this.getCore_reason());
		value.put(CORE_OPINION, this.getCore_opinion());
		value.put(CORE_INST_1, this.getCore_inst_1());
		value.put(CORE_INST_2, this.getCore_inst_2());
		value.put(CORE_INST_3, this.getCore_inst_3());
		value.put(CORE_INST_4, this.getCore_inst_4());
		value.put(CORE_INST_5, this.getCore_inst_5());
		value.put(CORE_DOCT_1, this.getCore_doct_1());
		value.put(CORE_DOCT_2, this.getCore_doct_2());
		value.put(CORE_DOCT_3, this.getCore_doct_3());
		value.put(CORE_DOCT_4, this.getCore_doct_4());
		value.put(CORE_DOCT_5, this.getCore_doct_5());
		value.put(CORE_DOCTOR, this.getCore_doct());
		value.put(CORE_DATE, this.getCore_date());
		myContext.getContentResolver().insert(CONTENT_URI_TB11, value);
	}
	
	public void selectHuiZhenRecord(int pro,int state){
		Cursor cursor = myContext.getContentResolver().query(CONTENT_URI_TB11, null,
				CORE_PROFILEID + "=" + pro + " AND "+CORE_STATE+"="+state, null, null);
		while(cursor.moveToNext()){
			this.core_profileid = cursor.getInt(cursor.getColumnIndex(CORE_PROFILEID));
			this.core_reason= cursor.getString(cursor.getColumnIndex(CORE_REASON));
			this.core_opinion = cursor.getString(cursor.getColumnIndex(CORE_OPINION));
			this.core_inst_1 = cursor.getString(cursor.getColumnIndex(CORE_INST_1));
			this.core_inst_2 = cursor.getString(cursor.getColumnIndex(CORE_INST_2));
			this.core_inst_3 = cursor.getString(cursor.getColumnIndex(CORE_INST_3));
			this.core_inst_4 = cursor.getString(cursor.getColumnIndex(CORE_INST_4));
			this.core_inst_5 = cursor.getString(cursor.getColumnIndex(CORE_INST_5));
			this.core_doct_1 = cursor.getString(cursor.getColumnIndex(CORE_DOCT_1));
			this.core_doct_2 = cursor.getString(cursor.getColumnIndex(CORE_DOCT_2));
			this.core_doct_3 = cursor.getString(cursor.getColumnIndex(CORE_DOCT_3));
			this.core_doct_4 = cursor.getString(cursor.getColumnIndex(CORE_DOCT_4));
			this.core_doct_5 = cursor.getString(cursor.getColumnIndex(CORE_DOCT_5));
			this.core_doct = cursor.getString(cursor.getColumnIndex(CORE_DOCTOR));
			this.core_date = cursor.getString(cursor.getColumnIndex(CORE_DATE));
			break;
		}
		cursor.close();
	}
	
	public void updateHuiZhenRecord(int pro,int state){
		ContentValues value;
		value = new ContentValues();
		value.put(CORE_REASON, this.getCore_reason());
		value.put(CORE_OPINION, this.getCore_opinion());
		value.put(CORE_INST_1, this.getCore_inst_1());
		value.put(CORE_INST_2, this.getCore_inst_2());
		value.put(CORE_INST_3, this.getCore_inst_3());
		value.put(CORE_INST_4, this.getCore_inst_4());
		value.put(CORE_INST_5, this.getCore_inst_5());
		value.put(CORE_DOCT_1, this.getCore_doct_1());
		value.put(CORE_DOCT_2, this.getCore_doct_2());
		value.put(CORE_DOCT_3, this.getCore_doct_3());
		value.put(CORE_DOCT_4, this.getCore_doct_4());
		value.put(CORE_DOCT_5, this.getCore_doct_5());
		value.put(CORE_DOCTOR, this.getCore_doct());
		value.put(CORE_DATE, this.getCore_date());
		myContext.getContentResolver().update(CONTENT_URI_TB11, value, 
				CORE_PROFILEID + "=" + pro + " AND "+CORE_STATE+"="+state, null);
	}
	
	public void deleteHuiZhenRecord(int pro){
		myContext.getContentResolver().delete(CONTENT_URI_TB11,
				CORE_PROFILEID + "=" + pro + "", null);
	}

}
